package com.lane.sidecn.product.web;

import org.springframework.beans.BeanUtils;

import com.lane.core.web.BaseController;
import com.lane.sidecn.product.model.Order;

/**
 * @author 张先宙 E-mail: zhangxianzhou_std@163.com
 * @version 1.0 创建时间：Jun 30, 2009 10:39:40 PM
 * 
 */

public class OrderController extends BaseController {

	private Order order;

	/**
	 * 添加订单
	 */
	public void add() {
		if (null == order) {
			printMessage("addOrderFail");// 添加失败
		}
		try {
			baseManager.save(order);// 保存订单
			printMessage("addOrderSuccess");
		} catch (Exception e) {
			printMessage("addOrderFail");// 保存失败
		}
	}

	/**
	 * 移除订单
	 */
	public void remove() {
		if (null == order) {
			printMessage("removeOrderFail");
		}
		try {
			// TODO 通过某一个值找到持久化对象，并将其从数据库中移除
			baseManager.remove(order);
			printMessage("removeOrderSuccess");
		} catch (Exception e) {
			printMessage("removeOrderFail");
		}
	}

	/**
	 * 
	 * 更新订单
	 */

	public void update() {
		Order oldOrder = find();
		if (null == oldOrder) {
			// printMessage("updateOrderItemFail");//TODO 更新失败
		}
		BeanUtils.copyProperties(oldOrder, order);
		try {
			baseManager.save(order);// 保存新的订单
			printMessage("updateOrderSuccess");
		} catch (Exception e) {
			printMessage("updateOrderFail");// 保存失败
		}

	}

	public Order find() {
		// TODO 通过某一个值找到持久化对象，并将其从数据库中移除
		return null;
	}

	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

}
